package com.example.benyq.mediaplayerdemo;

import android.annotation.SuppressLint;

/**
 * @author benyq
 * @date 17-12-12 10:24
 * @E-mail： 1520063035@qq.com
 * @description 将毫秒转化为分秒
 */
public class TimeUtils {

    @SuppressLint("DefaultLocale")
    public static String formatDuration(int duration) {
        duration /= 1000; // milliseconds into seconds
        int minute = duration / 60;
        int hour = minute / 60;
        minute %= 60;
        int second = duration % 60;
        if (hour != 0)
            return String.format("%2d:%02d:%02d", hour, minute, second);
        else
            return String.format("%02d:%02d", minute, second);
    }

}
